#!/bin/bash
mkdir -p /data/apps
cd /data/apps
wget http://download.douyouqu.net/node_exporter-1.2.2.linux-amd64.tar.gz
tar xf node_exporter-1.2.2.linux-amd64.tar.gz
mv /data/apps/node_exporter-1.2.2.linux-amd64 /data/apps/node_exporter
ln -s /data/apps/node_exporter/node_exporter /usr/bin/node_exporter
which node_exporter

cat > /lib/systemd/system/node_exporter.service <<EOF
[Unit]
Description=https://prometheus.io

[Service]
ExecStart=/data/apps/node_exporter/node_exporter
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl enable node_exporter;systemctl restart node_exporter